#include <iostream>
using namespace std;

typedef long long LL;
const int N = 2e5 + 10;
int n;
int a[N];
int f[N], g[N];
int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];

    for (int i = 1; i <= n; i++)
    {
        f[i] = g[i - 1] + a[i];
        g[i] = max(f[i - 1], g[i - 1]);
    }

    cout << max(f[n], g[n]) << endl;
    return 0;
}